<%@ Control %>
<%@ Register TagPrefix="CS" Namespace="CommunityServer.Controls" Assembly="CommunityServer.Controls" %>
<%@ Register TagPrefix="FileGalleries" Namespace="CommunityServer.Files.Controls" Assembly="CommunityServer.Files" %>
<%@ Import Namespace="CommunityServer.Files.Controls" %>
<%@ Import Namespace="CommunityServer.Files.Components" %>
<%@ Import Namespace="CommunityServer.Components" %>
<%@ Import Namespace="CommunityServer.Controls" %>
<%@ Import Namespace="CommunityServer" %>

<script language="C#" runat="server">

protected override void OnLoad (EventArgs e) 
{
	base.OnLoad(e);
	
	CSContext csContext = CSContext.Current;
	string baseUrl = FileGalleryUrls.Instance().ViewFolderGroup(csContext.GroupID);
	
	HyperLink PostDateLink = (HyperLink) Foldergrouplisting1.FindControl("PostDateLink");
	HyperLink RatingLink = (HyperLink) Foldergrouplisting1.FindControl("RatingLink");
	HyperLink CommentsLink = (HyperLink) Foldergrouplisting1.FindControl("CommentsLink");
	HyperLink DownloadLink = (HyperLink) Foldergrouplisting1.FindControl("DownloadLink");

	PostDateLink.Text = FileGalleryResourceManager.GetString( "Files_PortalEntryListing_TitlePostDate" );
	RatingLink.Text = FileGalleryResourceManager.GetString( "Files_PortalEntryListing_TitleRating" );
	CommentsLink.Text = FileGalleryResourceManager.GetString( "Files_PortalEntryListing_TitleReplies" );
	DownloadLink.Text = FileGalleryResourceManager.GetString( "Files_PortalEntryListing_TitleDownloads" );
	
	DownloadLink.NavigateUrl = baseUrl + "?Sort=Downloads";
	RatingLink.NavigateUrl = baseUrl + "?Sort=Ratings";
	PostDateLink.NavigateUrl = baseUrl + "?Sort=Date";
	CommentsLink.NavigateUrl = baseUrl + "?Sort=Comments";

	switch (Request.QueryString["Sort"])
	{
		case "Ratings":
			((PortalEntryListing) Foldergrouplisting1.FindControl("Entrylisting1")).SortBy = EntriesSortBy.Rating;
			RatingLink.Style["font-weight"] = "bold";
			break;
			
		case "Date":
			((PortalEntryListing) Foldergrouplisting1.FindControl("Entrylisting1")).SortBy = EntriesSortBy.PostDate;
			PostDateLink.Style["font-weight"] = "bold";
			break;
			
		case "Comments":
			((PortalEntryListing) Foldergrouplisting1.FindControl("Entrylisting1")).SortBy = EntriesSortBy.Comments;
			CommentsLink.Style["font-weight"] = "bold";
			break;
			
		default:
			((PortalEntryListing) Foldergrouplisting1.FindControl("Entrylisting1")).SortBy = EntriesSortBy.Downloads;
			DownloadLink.Style["font-weight"] = "bold";
			break;
	}		
}

</script>

<FileGalleries:FolderGroupListing runat="server" ID="Foldergrouplisting1">
<SkinTemplate>

<div class="CommonContentArea">
    <CS:AdPart runat = "Server" contentname="StandardTop" ID="ap">
	    <CS:Ads Zone="StandardTop" runat="server" id="ad" />
	</CS:AdPart>
	<h2 class="CommonTitle"><asp:Literal ID="GroupName" Runat="server" /></h2>
	<div class="CommonContent">
	
		<asp:HyperLink Runat="server" ID="DownloadLink" /> |
		<asp:HyperLink Runat="server" ID="RatingLink" /> |
		<asp:HyperLink Runat="server" ID="PostDateLink" /> |
		<asp:HyperLink Runat="server" ID="CommentsLink" />
		
		<FileGalleries:PortalEntryListing runat="server" ID="Entrylisting1" SortBy="Downloads" SkinName="Skin-PortalEntryListingExtended.ascx" Count="10" />
		
	</div>
	
	<CS:AdPart runat = "Server" contentname="StandardBottom" ID="ap2">
	    <CS:Ads Zone="StandardBottom" runat="server" id="ad2" />
	</CS:AdPart>	
</div>

</SkinTemplate>
</FileGalleries:FolderGroupListing>
